package com.xiaoxx.coin.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

@Getter
@AllArgsConstructor
public enum OrderStatusEnum {
    NEW("NEW", "新建订单"),
    PARTIALLY_FILLED("PARTIALLY_FILLED", "部分成交"),
    FILLED("FILLED", "全部成交"),
    CANCELED("CANCELED", "已撤销"),
    REJECTED("REJECTED", "订单被拒绝"),
    EXPIRED("EXPIRED", "订单过期(根据timeInForce参数规则)"),
    EXPIRED_IN_MATCH("EXPIRED_IN_MATCH", "订单被STP过期");

    private final String code;
    private final String description;


    // 根据code获取枚举对象
    public static OrderStatusEnum fromCode(String code) {
        for (OrderStatusEnum status : OrderStatusEnum.values()) {
            if (status.getCode().equals(code)) {
                return status;
            }
        }
        throw new IllegalArgumentException("Invalid Order Status code: " + code);
    }
}
